//
//  SoundDetailCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 lushan. All rights reserved.
//

#import "SoundDetailCell.h"
#import "UIImageView+WebCache.h"

@implementation SoundDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    self.picView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH / 16, HEIGHT / 40, WIDTH / 8, WIDTH / 8)];
    
    [self.contentView addSubview:self.picView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.picView.frame.origin.x + self.picView.frame.size.width + 10, self.picView.frame.origin.y * 1.5, WIDTH / 2, self.picView.frame.size.height / 4)];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:self.nameLabel];
    
    self.numImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.picView.frame.origin.x + self.picView.frame.size.width + 10, self.picView.frame.origin.y + self.picView.frame.size.height * 0.6, self.picView.frame.size.height / 4, self.picView.frame.size.height / 4)];
    self.numImage.image = [UIImage imageNamed:@"iconfont-31shengbo.png"];
    [self.contentView addSubview:self.numImage];
    
    self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.picView.frame.origin.x * 2 + self.picView.frame.size.width + 10, self.picView.frame.origin.y + self.picView.frame.size.height * 0.6, WIDTH / 4, self.picView.frame.size.height / 4)];
    self.countLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.countLabel];
    
    self.playButton = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * 0.8, self.picView.frame.origin.y + self.picView.frame.size.height / 4, self.picView.frame.size.height / 2, self.picView.frame.size.height / 2)];
    self.playButton.image = [UIImage imageNamed:@"bofang.png"];
    [self.contentView addSubview:self.playButton];
    
}

//set方法
-(void)setSoundDetailModel:(SoundDetailModel *)soundDetailModel{
    
    _soundDetailModel = soundDetailModel;
    self.nameLabel.text = self.soundDetailModel.title;
    self.countLabel.text = [NSString stringWithFormat:@"%ld", self.soundDetailModel.musicVisit];
    NSURL *url = [NSURL URLWithString:self.soundDetailModel.coverimg];
    [self.picView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"holderImage.jpg"]];

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
